home *** CD-ROM | disk | FTP | other *** search
- (*****************************************************************************)
- The Generic Hash Table (HTable) Object
-
- written by : Eric C. Wentz
-
- last mod date : September 26, 1989
-
- (*****************************************************************************)
-
- NOTE: These Units will not compile without several Units which can
- be found in GENERI.ARC, available this library. Specifically,
- Units GenDatum and FlexPntr.
-
-
- The HTable is a simple Generic Hash table, designed so that with very little
- effort it will be possible to Hash any data element desired. As the HTable is
- defined as an Object, having multiple Hash Tables takes even less effort.
- Using the FlexStack unit, it would be very easy to create a stack of Hash
- tables, which (I am told..) would make compiler writing an easier task. Be
- that as it may, more mundane Hashing can be achieved with greater ease than
- ever before, by using this Object. -- Enjoy!
-
-
- (**************************************************)
-
- The HTable uses an Externally-Chained Hash Table representation, and the
- most basic Hashing function I know of, yet gives surprisingly good results.
- The Hash function is:
-
- H := (Sum(Ord(CharactersInString))) MOD (LengthOfArray)
-
- which returns 0..LengthOfArray-1. {Array is zero-based}
-
- For some obscure mathematical reason, it turns out that the best lengths for
- such arrays are Prime numbers, so in Unit GenTable, the Constant MaxEntry is
- defined to be 23. Feel free to redefine it to suit your application. I
- suggest that you chose an appropriate prime such that the length trys to
- approximate 1/3 to 1/6 of the number of entries you expect to encounter. If
- you have no idea, redefine MaxEntry to be as large as you can.